<template>
	<view class="p20r">
		<u-form :model="form" ref="uForm">
			<view class="pl20r pr20r bor-rad14r" style="background-color: #fff;">
				<u-form-item label-width="auto" label="姓名">
					<u-input input-align="right" v-model="form.name" placeholder="请输入你的姓名" />
				</u-form-item>
				<u-form-item label-width="auto" label="性别">
					<u-input input-align="right" v-model="form.gender" @tap='setgender' disabled
						placeholder="请选择你的性别" />
					<view class="cuIcon-right" slot="right" @tap='setgender'></view>
				</u-form-item>
				<!-- <u-form-item label-width="auto" label="年龄">
					<u-input input-align="right" v-model="form.age" placeholder="请输入你的年龄" />
				</u-form-item> -->
				<u-form-item label-width="auto" label="民族">
					<u-input input-align="right" v-model="form.nation" placeholder="请输入你的民族" />
				</u-form-item>
				<u-form-item label-width="auto" label="出生日期">
					<u-input input-align="right" v-model="form.birthday" @tap="show=true" disabled
						placeholder="请选择你的生日" />
					<view class="cuIcon-right" @tap="show=true" slot="right"></view>
				</u-form-item>
				<u-form-item label-width="auto" label="联系电话">
					<u-input input-align="right" v-model="form.iphone" placeholder="请输入你的联系电话" />
				</u-form-item>
				<u-form-item label-width="auto" label="婚姻">
					<u-input input-align="right" v-model="form.marriage" @tap="setMar()" placeholder="请输入你的婚姻状况"
						disabled />
					<view class="cuIcon-right" @tap="setMar()" slot="right"></view>
				</u-form-item>
				<u-form-item label-width="auto" label="现居">
					<u-input input-align="right" v-model="form.current_residence" placeholder="请输入你的现居地址" />
				</u-form-item>
				<u-form-item label-width="auto" label="籍贯">
					<u-input input-align="right" v-model="form.native_place" placeholder="请输入你的籍贯" />
					<!-- <view class="cuIcon-right" slot="right" @tap='educationShow=true'></view> -->
				</u-form-item>
				<u-form-item label-width="auto" label="意向岗位">
					<u-input input-align="right" v-model="form.intended_position" placeholder="请输入你的意向岗位" />
				</u-form-item>
				<u-form-item label-width="auto" label="工作经历" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.work_experience" type="textarea" placeholder="请输入你的工作经历（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.work_experience.length||0}}/500</view>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="教育经历" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.educational_experience" type="textarea" placeholder="请输入你的教育经历（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.educational_experience.length||0}}/500</view>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="电脑/外语能力" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.computer_language" type="textarea" placeholder="请输入你的电脑/外语能力（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.computer_language.length||0}}/500</view>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="特长/自我评价" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.self_evaluation" type="textarea" placeholder="请输入你的特长/自我评价（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.self_evaluation.length||0}}/500</view>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="简历小照片" label-position="top">
					<view class=" " @tap="upImg('image')">
						<image :src="form.image?$baseUrl+form.image:'/static/img/my/6jianli-photo.png'" class="w340r"
							mode="widthFix"></image>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="获奖证书" label-position="top">
					<view class="" @tap="upImg('certificate_image')">
						<image
							:src="form.certificate_image?$baseUrl+form.certificate_image:'/static/img/my/6jianli-photo.png'"
							class="w340r" mode="widthFix"></image>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="自荐信" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.letter_of_self" type="textarea" placeholder="请输入你的自荐信（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.letter_of_self.length||0}}/500</view>
					</view>
				</u-form-item>

			</view>

		</u-form>
		<view class="x-c bg-zs bor-rad14r h100r color-fff mt50r" @tap="submit">提交</view>
		<u-picker mode="time" @confirm="setTime" v-model="show"></u-picker>
		<u-picker mode="time" @confirm="setTimeRz" v-model="showRz"></u-picker>
		<!-- 学历 -->
		<u-select v-model="educationShow" label-name='name' value-name='id' @confirm="seteducation" :list="educationL">
		</u-select>
	</view>
</template>

<script>
	export default {
		name:'resume',
		data() {
			return {
				show: false,
				showRz: false, //入职时间
				educationShow: false, //学历
				educationL: [], //学历
				form: {
					name: '', //姓名
					gender: '', //性别
					nation: '', //民族
					marriage: '', //生日
					iphone: '', //联系电话
					marriage: '', //是否婚姻
					current_residence: '', //现居
					native_place: '', //籍贯
					intended_position: '', //意向岗位
					work_experience: '', //工作经历
					educational_experience: '', //教育经历
					computer_language: '', //电脑/外语能力
					self_evaluation: '', //特长/自我评价
					image: '', //简历小照片
					certificate_image: '', //获奖证书
					letter_of_self: '', //自荐信
					json: ''
					// id:''//VIP岗位列表id （修改的时候必传 （添加的时候不用传））
				},
				type: '',
			};
		},
		onShow() {

		},
		onLoad() {
			this.myResume()
		},
		methods: {
			myResume() {
				this.$api.myResume().then(res => {
					//如果返回的有值就赋值
					if(res.data) {
						this.form = res.data
					}
				})
			},
			// myResumeInfo() {
			// 	this.$api.myResumeInfo().then(res => {
					
			// 	})
			// },
			submit() {
				this.$api.myResumeEdit(this.form).then(res => {
					this.$msg(res.msg)
					setTimeout(() => {
						uni.navigateBack()
					}, 1000)
				})
			},
			setgender() { //性别
				let that = this
				let itemList = ['男', '女']
				uni.showActionSheet({
					itemList,
					success(res) {
						that.form.gender = itemList[res.tapIndex]
					}
				})
			},
			setMar() { //设置婚姻状态
				let that = this
				let itemList = ['已婚', '未婚']
				uni.showActionSheet({
					itemList,
					success(res) {
						that.form.marriage = itemList[res.tapIndex]
					}
				})
			},
			upImg(value) {
				this.$tool.upload().then(res => {
					console.log(res);
					this.form[value] = res.data.url
				})
			},
			setTime(e) {
				console.log(e);
				this.form.birthday = "" + e.year + '-' + e.day + '-' + e.month
			},
			setTimeRz(e) {
				console.log(e);
				this.form.estimated_entry_time = "" + e.year + '-' + e.day + '-' + e.month
			},
		}
	}
</script>

<style lang="scss">

</style>
